<template>
  <div>
    <!-- table -->
    <FilterTable
      height="250"
      ref="listModal"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :onColumnsChange="columns => this.columns = columns"
      :onRowSelectChange="selectChange"
    ></FilterTable>
    <div class="dialogBottmView" :style="{position: 'absolute',
        left: 0,
        bottom: 0,
        right: 0,
        zIndex: 9,
        borderTop: '1px solid #e9e9e9',
        padding: '10px 20px',
        background: '#fff',
        textAlign: 'right'}">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button @click="saveDialog" type="primary">确定</el-button>
    </div>

  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { getUserRoleName} from '@/api/admin/notice/dcsNoticeMaintain/index';
export default {
  mixins: [dictionary],
  data() {
    return {
      columns: this.creatHeader(),
      fetchApi: getUserRoleName, // TODO 缺少获取车场角色接口
      fetchParams: {
        companyId:3
      },
      selectedRows:null
    };
  },
  
  methods: {
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '角色名称', dataIndex: 'roleName', sorter: true }
      ];
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows
      console.log(this.selectedRows);
    },
    //保存
    saveDialog() {
      this.$emit('close', { visible: false ,"data":this.selectedRows});
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false });
    }

  }

};
</script>

<style lang="less" scoped>
</style>
